package com.object.module.cbb.controller;

import com.object.configuration.utils.PageUtils;
import com.object.configuration.utils.Q;
import com.object.module.cbb.entity.CbbOrderEntity;
import com.object.module.cbb.service.CbbOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.Map;


/**
 * 订单
 *
 * @author 小🌤
 * @email 1578442339@qq.com
 * @date 2022-03-28 11:17:49
 */
@RestController
@RequestMapping("/cbb/cbborder")
public class CbbOrderController {
    @Autowired
    private CbbOrderService cbbOrderService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public Q list(@RequestParam Map<String, Object> params) {
        PageUtils page = cbbOrderService.queryPage(params);
        return Q.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{orUuid}")
    public Q info(@PathVariable("orUuid") String orUuid) {
            CbbOrderEntity cbbOrder = cbbOrderService.infoOrder(orUuid);
            return Q.ok().put("cbbOrder", cbbOrder);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public Q save(@RequestBody CbbOrderEntity cbbOrder) {
            cbbOrderService.save(cbbOrder);
            return Q.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public Q update(@RequestBody CbbOrderEntity cbbOrder) {
            cbbOrderService.updateById(cbbOrder);
            return Q.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public Q delete(@RequestBody String[] orUuids) {
            cbbOrderService.removeByIds(Arrays.asList(orUuids));
            return Q.ok();
    }

}
